<template>
    <div>
        <page-header title="运费模版" />
        <page-main>
            <el-row>
                <el-col :md="24" :lg="16">
                    <el-form ref="form" :model="form" :rules="rules" label-width="120px" label-suffix="：">
                        <el-row>
                            <el-col :md="24" :lg="16">
                                <el-form-item label="名称" prop="name">
                                    <el-input v-model="form.name" placeholder="请输入名称" />
                                </el-form-item>
                                <el-form-item label="发货地址" prop="address">
                                    <cascader-area v-model="form.address" />
                                </el-form-item>
                                <el-form-item label="计价方式">
                                    <el-radio-group v-model="form.type">
                                        <el-radio-button :label="1">按件数</el-radio-button>
                                        <el-radio-button :label="2">按重量</el-radio-button>
                                    </el-radio-group>
                                </el-form-item>
                            </el-col>
                            <el-col :span="24">
                                <el-form-item label="运费模版">
                                    <div class="freight">
                                        <el-card shadow="never">
                                            <div slot="header">默认运费</div>
                                            <el-row :gutter="20">
                                                <el-col :md="6">
                                                    <el-input v-model="form.first_step" v-format-int size="small">
                                                        <template slot="prepend">{{ form.type == 1 ? '首件' : '首重' }}</template>
                                                        <template slot="append">{{ form.type == 1 ? '件' : 'kg' }}</template>
                                                    </el-input>
                                                </el-col>
                                                <el-col :md="6">
                                                    <el-input v-model="form.first_price" v-format-price size="small">
                                                        <template slot="prepend">首费</template>
                                                        <template slot="append">元</template>
                                                    </el-input>
                                                </el-col>
                                                <el-col :md="6">
                                                    <el-input v-model="form.continued_step" v-format-int size="small">
                                                        <template slot="prepend">{{ form.type == 1 ? '续件' : '续重' }}</template>
                                                        <template slot="append">{{ form.type == 1 ? '件' : 'kg' }}</template>
                                                    </el-input>
                                                </el-col>
                                                <el-col :md="6">
                                                    <el-input v-model="form.continued_price" v-format-price size="small">
                                                        <template slot="prepend">续费</template>
                                                        <template slot="append">元</template>
                                                    </el-input>
                                                </el-col>
                                            </el-row>
                                        </el-card>
                                        <el-row>
                                            <el-col :span="24">
                                                <Freight :data="form.table" :type="form.type" />
                                            </el-col>
                                        </el-row>
                                    </div>
                                </el-form-item>
                            </el-col>
                            <el-col :md="24" :lg="16">
                                <el-form-item label="是否启用">
                                    <el-radio-group v-model="form.status">
                                        <el-radio-button :label="1">启用</el-radio-button>
                                        <el-radio-button :label="0">停用</el-radio-button>
                                    </el-radio-group>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                </el-col>
            </el-row>
        </page-main>
    </div>
</template>

<script>
import Freight from './components/Freight/index'

export default {
    name: 'DeliveryDetail',
    components: {
        Freight
    },
    data() {
        return {
            form: {
                id: this.id,
                name: '',
                address: [],
                isfreeshipping: 0,
                type: 1,
                status: 1,
                first_step: '',
                first_price: '',
                continued_step: '',
                continued_price: '',
                table: []
            },
            rules: {
                name: [
                    { required: true, message: '请输入名称', trigger: 'blur' }
                ]
            }
        }
    },
    mounted() {},
    methods: {}
}
</script>

<style lang="scss" scoped>
.freight {
    line-height: initial;
    ::v-deep .el-card {
        line-height: initial;
        margin-bottom: 10px;
        .el-input__inner {
            text-align: center;
        }
    }
}
</style>
